{% extends "base.html" %}

{% block content %}
<section id="addlist">
    <div class="row">
        <div class="col-md-12">
            <ol class="breadcrumb" style="margin-top:6px;">
                <li>添加未关联的电影，共{{ movie_count }}部</li>
            </ol>
        </div>
        <div class="col-md-12">
            {% for v in page_data %}
                <div class="media">
                    <h4 class="media-heading">{{ v[1] }}<a href="javascript:void(0);" class="label label-primary pull-right" onclick="javascript:post(this)" name="{{v[1]}}" ftype={{v[0]}} ><span class="glyphicon glyphicon-play"></span>添加影片</a></h4>
                    <script type="text/javascript" src="{{ static_url('base/js/jquery.min.js') }}"></script>
                    <script type="text/javascript">
                        function post(obj){
                            event.preventDefault();
                            var ftype = $(obj).attr('ftype');
                            var name = $(obj).attr('name');
                            $.ajax({
                                type: "POST",
                                url: "/add",
                                data: {ftype:ftype,name:name},
                                dataType: 'json',
                                success: function(result){
                                    if (result.code == 0){
                                        $(obj).parent().parent().remove();
                                    }else{
                                        alert(result.msg);
                                        // console.log(result.msg);
                                    }
                                },
                                error: function(result){
                                    // console.log(result.msg);
                                }
                            });
                        };
                    </script>
                </div>
            {% end %}
        </div>
        <div class="col-md-12 text-center">
            <nav aria-label="Page navigation">
            </nav>
        </div>
    </div>
</section>
<script type="text/javascript">

</script>
{% end %}